<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<script type="text/javascript" src="../../js/boot.js"></script>
		<title></title>
	</head>

	<body>

		<div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;height:100%;" bodyStyle="padding:0;border:0;">
			<div title="基础信息">
				<div id="basicForm">
					<table align="left">
						<tr>
							<td align="right">页面编号：</td>
							<td align="left"><input name="pageID" class="mini-textbox" enabled="false" width="260"></td>
							<td align="right">文件名称：</td>
							<td align="left"><input name="fileName" class="mini-textbox" width="260" /></td>
						</tr>
						<tr>
							<td align="right">存储路径：</td>
							<td>
								<input class="mini-treeselect" id="savePath" name="savePath" textField="label" valueField="path" parentField="parentID" checkRecursive="true" multiSelect="false" showFolderCheckBox="false" expandOnLoad="0" showClose="true" oncloseclick="onCloseClick" popupWidth="300" style="width: 90%" />
							</td>
							<td align="right">说明：</td>
							<td align="left"><input name="description" class="mini-textbox" width="260" /></td>
						</tr>
						<tr>
							<td align="right">模板类型：</td>
							<td align="left">
								<input name="templatType" class="mini-combobox" textField="text" valueField="id" data="templetTypes" width="260" />
							</td>
							<td align="right">模板名称：</td>
							<td>
								<input class="mini-treeselect" id="templetName" name="templetName" textField="label" valueField="path" parentField="parentID" checkRecursive="true" multiSelect="false" showFolderCheckBox="false" expandOnLoad="0" showClose="true" oncloseclick="onCloseClick" popupWidth="300" style="width: 90%" />
							</td>
						</tr>
						<tr>
							<td align="right">查询表名称：</td>
							<td align="left">
								<input id="listTableName" name="listTableName" class="mini-buttonedit" onbuttonclick="openSelectTableDialog" selectOnFocus="true" width="260" />
								<input id="listTableID" name="listTableID" class="mini-hidden" />
							</td>
							<td align="right">详情表名称：</td>
							<td align="left">
								<input id="detailTableName" name="detailTableName" class="mini-buttonedit" onbuttonclick="openSelectTableDialog" selectOnFocus="true" width="260" />
								<input id="detailTableID" name="detailTableID" class="mini-hidden" />
							</td>
						</tr>
						<tr>
							<td align="right">实体类：</td>
							<td align="left">
								<input id="className" name="className" class="mini-buttonedit" onbuttonclick="openSelectClassDialog" selectOnFocus="true" width="260" />
								<input id="tableID" name="tableID" class="mini-hidden" />
							</td>
							<td align="right">排序：</td>
							<td align="left"><input name="sequence" class="mini-spinner" minValue="1" /></td>
						</tr>
						<tr>
							<td align="center" colspan=4>
								<a class="mini-button mini-button-primary" onclick="doSave()">保存</a>
								<a class="mini-button mini-button-primary" onclick="doCreate()">生成文件</a>
							</td>
						</tr>
					</table>
				</div>
			</div>

			<!--
	1、查询条件定义
		标题，
		名称，
		比较符：等于，小于，大于，小于等于，大于等于，相似，不等于，允许两个比较符
		数据类型：整型，字符串
		允许重复
		条件类型：必选，常用，高级
		顺序
-->
			<!--
	2、按钮定义：标题，名称，方法名称 ，方法定义，顺序
-->
			<!--
	3、列表定义：标题，名称，类型，顺序
-->
			<div title="列表定义">
				<fieldset style="width:99%;height:32%;">
					<legend><span>查询条件</span></legend>
					<div id="listSearchGrid" class="mini-datagrid" style="width: 100%;height:92%;" showPager="false" idField="fieldID" allowResize="true" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
						<div property="columns">
							<div field="+" value="+" width="20">+</div>
							<div field="index" type="indexcolumn" width="30"></div>
							<div name="name" field="name" displayField="description" headerAlign="center" width="120">字段名称
								<input property="editor" class="mini-lookup" style="width:100%;" minWidth="120" id="listSearchGrid_name_lookup" textField="description" valueField="fieldName" propertyField="propertyName" value="" text="" popupWidth="auto" popup="#listSearchGridNameGridPanel" grid="#listSearchGridFieldGrid" onshowpopup="listSearchGridNameOnShowPopup" onhidepopup="listSearchGridFieldOnHidePopup" />
							</div>
							<div name="dataType" field="dataType" headerAlign="center" width="80">数据类型
								<input property="editor" class="mini-textbox" style="width:100%;" minWidth="80" />
							</div>
							<div name="title" field="title" headerAlign="center" width="120">标题定义
								<input property="editor" class="mini-textbox" style="width:100%;" minWidth="120" />
							</div>
							<div name="property" field="property" headerAlign="center" width="120">属性定义
								<input property="editor" class="mini-textbox" style="width:100%;" minWidth="120" />
							</div>
							<div type="comboboxcolumn" autoShowPopup="true" name="conditionType" field="conditionType" width="60" align="center" headerAlign="center">条件类型
								<input property="editor" class="mini-combobox" style="width:100%;" data="conditionTypes" />
							</div>
							<div type="comboboxcolumn" autoShowPopup="true" name="comparison" field="comparison" width="60" align="center" headerAlign="center">比较符
								<input property="editor" class="mini-combobox" style="width:100%;" data="CONST.compareTypes" />
							</div>
							<div name="defaultValue" field="defaultValue" headerAlign="center" width="80">默认值
								<input property="editor" class="mini-textbox" style="width:100%;" minWidth="80" />
							</div>
							<div name="sequence" headerAlign="center" width="60">排序</div>
							<div field="-" value="-" width="20">-</div>
						</div>
					</div>
				</fieldset>
				<div style="width:99%;height:58%;">
					<div style="float:left ; width:30%; height:100%;">
						<fieldset style="width: 100%;height:100%;">
							<legend><span>操作按钮</span></legend>
							<div id="listButtonGrid" class="mini-datagrid" style="width:100%;height:92%;" showPager="false" idField="fieldID" allowResize="true" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
								<div property="columns">
									<div field="index" type="indexcolumn" width="30"></div>
									<div name="title" field="title" headerAlign="center" width="100">标题</div>
									<div type="checkboxcolumn" field="used" trueValue="1" falseValue="0" width="30" headerAlign="center">使用</div>
									<div name="sequence" headerAlign="center" width="60">排序</div>
								</div>
							</div>
						</fieldset>
					</div>
					<div style="float:left ; width:70%; height:100%;">
						<fieldset style="width: 100%;height:100%;">
							<legend><span>列表显示</span></legend>
							<div id="listFieldGrid" class="mini-datagrid" style="width:100%;height:92%;" showPager="false" idField="fieldID" allowResize="true" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
								<div property="columns">
									<div field="index" type="indexcolumn" width="30"></div>
									<div name="propertyName" field="propertyName" headerAlign="center" width="150">名称
										<input property="editor" class="mini-textbox" style="width:100%;" minWidth="155" />
									</div>
									<div name="description" field="description" headerAlign="center" width="150">标题
										<input property="editor" class="mini-textbox" style="width:100%;" minWidth="155" />
									</div>
									<div name="format" field="format" headerAlign="center" width="150">格式
										<input property="editor" class="mini-textbox" style="width:100%;" minWidth="155" />
									</div>
									<div name="width" field="width" headerAlign="center" width="40">列宽
										<input property="editor" class="mini-textbox" style="width:100%;" minWidth="40" />
									</div>
									<div type="comboboxcolumn" autoShowPopup="true" name="orderBy" field="orderBy" width="50" align="center" headerAlign="center">排序
										<input property="editor" class="mini-combobox" style="width:100%;" data="orderByTypes" />
									</div>
									<div type="checkboxcolumn" field="used" trueValue="1" falseValue="0" width="30" headerAlign="center">显示</div>
									<div name="sequence" headerAlign="center" width="60">排序</div>
								</div>
							</div>
						</fieldset>
					</div>
				</div>
			</div>
			<!--
	1、查询条件定义
		标题，
		名称，
		比较符：等于，小于，大于，小于等于，大于等于，相似，不等于，允许两个比较符
		数据类型：整型，字符串
		允许重复
		条件类型：
		顺序
	2、按钮定义：标题，名称，方法名称 ，方法定义，顺序
	3、列表定义：标题，名称，类型，顺序
	4、表单定义：标题，名称，类型，顺序
	5、模板输出定义
-->
			<div title="表单定义">
				<div style="width:99%;height:38%;">
					<div style="float:left ; width:50%; height:100%;">
						<fieldset style="width: 100%;height:100%;">
							<legend><span>基本参数</span></legend>
							<div id="detailBasicForm" class="fieldset-body">
								<table class="form-table" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td align="right">窗体宽度：</td>
										<td align="left"><input name="formWidth" class="mini-textbox" width="260" /></td>
									</tr>
									<tr>
										<td align="right">窗体高度：</td>
										<td align="left"><input name="formHeight" class="mini-textbox" width="260" /></td>
									</tr>
									<tr>
										<td align="right">每行列数：</td>
										<td align="left"><input name="colCount" class="mini-textbox" width="260" /></td>
									</tr>
								</table>
							</div>
						</fieldset>
					</div>
					<div style="float:left ; width:50%; height:100%;">
						<fieldset style="width: 100%;height:100%;">
							<legend><span>操作按钮</span></legend>
							<div id="detailButtonGrid" class="mini-datagrid" style="width:100%;height:92%;" showPager="false" idField="fieldID" allowResize="true" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
								<div property="columns">
									<div field="+" value="+" width="20">+</div>
									<div field="index" type="indexcolumn" width="30"></div>
									<div type="comboboxcolumn" autoShowPopup="true" name="name" field="name" width="100" align="center" headerAlign="center">方法名称
										<input property="editor" class="mini-combobox" style="width:100%;" data="CONST.buttonNames" />
									</div>
									<div name="sequence" headerAlign="center" width="60">排序</div>
									<div field="-" value="-" width="20">-</div>
								</div>
							</div>
						</fieldset>
					</div>
				</div>

				<div style="width:99%;height:60%;">
					<fieldset style="width: 100%;height:100%;">
						<legend><span>列表显示</span></legend>
						<div id="detailFieldGrid" class="mini-datagrid" style="width:100%;height:96%;" showPager="false" idField="fieldID" allowResize="true" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
							<div property="columns">
								<div field="index" type="indexcolumn" width="30"></div>
								<div name="propertyName" field="propertyName" headerAlign="center" width="150">名称
									<input property="editor" class="mini-textbox" style="width:100%;" minWidth="155" />
								</div>
								<div name="description" field="description" headerAlign="center" width="150">标题
									<input property="editor" class="mini-textbox" style="width:100%;" minWidth="155" />
								</div>
								<div name="defaultValue" field="defaultValue" headerAlign="center" width="100">默认值
									<input property="editor" class="mini-textbox" style="width:100%;" minWidth="100" />
								</div>
								<div name="minValue" field="minValue" headerAlign="center" width="40">最小值
									<input property="editor" class="mini-textbox" style="width:100%;" minWidth="60" />
								</div>
								<div name="maxValue" field="maxValue" headerAlign="center" width="40">最大值
									<input property="editor" class="mini-textbox" style="width:100%;" minWidth="60" />
								</div>
								<div type="checkboxcolumn" field="used" trueValue="1" falseValue="0" width="30" headerAlign="center">显示</div>
								<div name="sequence" headerAlign="center" width="60">排序</div>
							</div>
						</div>
					</fieldset>
				</div>
			</div>
		</div>

		<!--1号楼一层，13号，2点4点半，113房间-->
		<!--
	1、查询条件定义
		标题，
		名称，
		比较符：等于，小于，大于，小于等于，大于等于，相似，不等于，允许两个比较符
		数据类型：整型，字符串
		允许重复
		条件类型：
		顺序
	2、按钮定义：标题，名称，方法名称 ，方法定义，顺序
	3、列表定义：标题，名称，类型，顺序
	4、表单定义：标题，名称，类型，顺序
	5、模板输出定义
-->

		<div id="listSearchGridNameGridPanel" class="mini-panel" title="header" iconCls="icon-add" style="width:600px;height:400px;" visible="false" showToolbar="true" showCloseButton="true" showHeader="true" bodyStyle="padding:0" borderStyle="border:0" showPageSize="false" showPageIndex="false">
			<div id="listSearchGridFieldGrid" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:0" onRowclick="listSearchGridFieldGridSelectedRowClick">
				<div property="columns">
					<div type="checkcolumn">#</div>
					<div field="fieldName" width="160" headerAlign="center" allowSort="true">字段名称</div>
					<div field="propertyName" width="160" headerAlign="center" allowSort="true">字段属性</div>
					<div field="type" width="90" headerAlign="center" allowSort="true">数据类型</div>
					<div field="description" width="160" headerAlign="center" allowSort="true">说明</div>
				</div>
			</div>
		</div>

	</body>

	<script type="text/javascript">
		templetTypes = [{
			id: "表格",
			text: "表格"
		}, {
			id: "表单",
			text: "表单"
		}, {
			id: "组合",
			text: "组合"
		}];

		conditionTypes = [{
			id: "常用",
			text: "常用"
		}, {
			id: "高级",
			text: "高级"
		}, {
			id: "必选",
			text: "必选"
		}];

		orderByTypes = [{
			id: "",
			text: ""
		}, {
			id: "ASC",
			text: "升序"
		}, {
			id: "DESC",
			text: "降序"
		}];

		miniInit();

		/************************************************************************
		 * 基础定义
		 ************************************************************************/
		var basicForm = new mini.Form("#basicForm"); // 基础信息表单
		//存储路径
		var savePath = mini.get("savePath");
		savePath.load(http.getUrl("/sys/menu/getHtmlPath.do"));
		//html模板文件
		var templetName = mini.get("templetName");
		templetName.load(http.getUrl("/sys/menu/getTempletHtml.do"));

		/************************************************************************
		 * 列表-查询条件定义
		 ************************************************************************/
		var listSearchGrid = mini.get("listSearchGrid");
		listSearchGrid.on("drawcell", function(e) {
			//action列，超连接操作按钮
			if(e.column.name == "sequence") {
				var uid = e.record._uid;
				e.cellStyle = "text-align:center";
				e.cellHtml = '<a href="javascript:listSearchGridMoveRow(\'' + uid + '\', -1)">上移</a>&nbsp; ' +
					'<a href="javascript:listSearchGridMoveRow(\'' + uid + '\', +2)">下移</a>';
			} else if(e.column.header == "+") {
				e.cellHtml = "+";
			} else if(e.column.header == "-") {
				e.cellHtml = "-";
			}
		});
		// 移动行数据
		function listSearchGridMoveRow(row_uid, count) {
			var row = listSearchGrid.getRowByUID(row_uid);
			var index = listSearchGrid.indexOf(row);
			listSearchGrid.moveRow(row, index + count);
		}
		// 标题栏点击事件
		listSearchGrid.on("headercellclick", function(e) {
			// 如果点击了标题栏的加号，则增加一行
			if(e.column.header == "+") {
				addlistSearchGridField(0);
			}
		});
		// 单元格点击事件
		listSearchGrid.on("cellclick", function(e) {
			var data = listSearchGrid.getSelected();
			var index = listSearchGrid.indexOf(data);
			var header = e.column.header;
			// 如果点击了加号一列的单元格，则在当前行下面增加一行
			if(header == "+") {
				addlistSearchGridField(index + 1);
			}
			// 如果点击了减号一列的单元格，则删除当前行
			else if(header == "-") {
				mini.confirm("确认删除该数据信息吗？", "删除操作", function(e) {
					if(e == "ok") {
						listSearchGrid.removeRow(data);
					}
				});
			}
		});
		// 在指定的行号处添加一行记录
		function addlistSearchGridField(index) {
			listSearchGrid.addRow({
				"+": "+",
				"-": "-",
				"conditionType": '常用',
				"comparison": '等于'
			}, index);
		}

		/************************************************************************
		 * 列表-查询条件-字段名称定义
		 ************************************************************************/
		var listSearchGridFieldGrid = mini.get("listSearchGridFieldGrid"); // 字段名称选择弹出表格
		var listSearchGridSelectedRow = null; // 字段名称表格当前操作的行
		var listSearchGridFieldGridSelectedRow = null; // 字段名称选择弹出表格当前操作的行
		listSearchGridFieldGrid.set({
			url: http.getUrl("/plat/field/list.do")
		});
		// 查询定义配置页的字段名称列点击事件
		function listSearchGridNameOnSearchClick(e) {
			// 从基础配置中获取指定的表或视图编号
			debugger
			var tableID = basicForm.getData().listTableID;
			if(!tableID) {
				mini.alert("请先选择要操作的表或视图名称", "提示", null);
				return;
			}
			// 加载表对应包含的所有字段的定义
			listSearchGridFieldGrid.load({
				"tableID": tableID
			});
		}
		// 查询定义配置页的字段名称选择弹出窗的关闭事件
		function onlistSearchGridPanelCloseClick(e) {
			var lookup = mini.get("listSearchGrid_name_lookup");
			lookup.hidePopup();
		}
		// 查询定义配置页的字段名称选择弹出窗事件
		function listSearchGridNameOnShowPopup(e) {
			//debugger
			listSearchGridSelectedRow = listSearchGrid.getSelected();
			listSearchGridNameOnSearchClick(e);
		}
		// 查询定义配置页的字段名称选择弹出窗的鼠标点击事件
		function listSearchGridFieldGridSelectedRowClick(e) {
			debugger
			listSearchGridFieldGridSelectedRow = listSearchGridFieldGrid.getSelected();
			if(listSearchGridFieldGridSelectedRow != null) {
				if(listSearchGridSelectedRow.title == null || listSearchGridSelectedRow.title == '') {
					listSearchGridSelectedRow.title = listSearchGridFieldGridSelectedRow.description;
				}
				if(listSearchGridSelectedRow.property == null || listSearchGridSelectedRow.property == '') {
					listSearchGridSelectedRow.property = listSearchGridFieldGridSelectedRow.propertyName;
				}
				listSearchGridSelectedRow.dataType = listSearchGridFieldGridSelectedRow.type
			}
		}

		// 查询定义配置页的字段名称选择弹出窗关闭事件
		function listSearchGridFieldOnHidePopup(e) {}

		/************************************************************************
		 * 列表-按钮定义
		 ************************************************************************/
		var listButtonGrid = mini.get("listButtonGrid");
		var listButtonGridData = [{
			title: "查询",
			name: "doSearch",
			used: 1,
			sequence: 1
		}, {
			title: "新增",
			name: "doAdd",
			used: 1,
			sequence: 2
		}, {
			title: "修改",
			name: "doEdit",
			used: 1,
			sequence: 3
		}, {
			title: "保存",
			name: "doSave",
			used: 1,
			sequence: 4
		}, {
			title: "删除",
			name: "doDelete",
			used: 1,
			sequence: 5
		}, {
			title: "导出",
			name: "doOutput",
			used: 1,
			sequence: 6
		}, {
			title: "导入",
			name: "doInput",
			used: 1,
			sequence: 7
		}];
		listButtonGrid.setData(listButtonGridData);

		listButtonGrid.on("drawcell", function(e) {
			//action列，超连接操作按钮
			if(e.column.name == "sequence") {
				var uid = e.record._uid;
				e.cellStyle = "text-align:center";
				e.cellHtml = '<a href="javascript:listButtonGridMoveRow(\'' + uid + '\', -1)">上移</a>&nbsp; ' +
					'<a href="javascript:listButtonGridMoveRow(\'' + uid + '\', +2)">下移</a>';
			}
		});
		// 移动行数据
		function listButtonGridMoveRow(row_uid, count) {
			var row = listButtonGrid.getRowByUID(row_uid);
			var index = listButtonGrid.indexOf(row);
			listButtonGrid.moveRow(row, index + count);
		}

		/************************************************************************
		 * 列表-显示字段定义
		 ************************************************************************/
		var listFieldGrid = mini.get("listFieldGrid");
		listFieldGrid.set({
			url: http.getUrl("/plat/field/list.do")
		});
		listFieldGrid.on("drawcell", function(e) {
			//action列，超连接操作按钮
			if(e.column.name == "sequence") {
				var uid = e.record._uid;
				e.cellStyle = "text-align:center";
				e.cellHtml = '<a href="javascript:listFieldGridMoveRow(\'' + uid + '\', -1)">上移</a>&nbsp; ' +
					'<a href="javascript:listFieldGridMoveRow(\'' + uid + '\', +2)">下移</a>';
			}
		});
		// 移动行数据
		function listFieldGridMoveRow(row_uid, count) {
			var row = listFieldGrid.getRowByUID(row_uid);
			var index = listFieldGrid.indexOf(row);
			listFieldGrid.moveRow(row, index + count);
		}

		/************************************************************************
		 * 详情-表单-基础定义
		 ************************************************************************/
		var detailBasicForm = new mini.Form("#detailBasicForm");

		/************************************************************************
		 * 详情-表单-按钮定义
		 ************************************************************************/
		var detailButtonGrid = mini.get("detailButtonGrid");
		detailButtonGrid.on("drawcell", function(e) {
			//action列，超连接操作按钮
			if(e.column.name == "sequence") {
				var uid = e.record._uid;
				e.cellStyle = "text-align:center";
				e.cellHtml = '<a href="javascript:detailButtonGridMoveRow(\'' + uid + '\', -1)">上移</a>&nbsp; ' +
					'<a href="javascript:detailButtonGridMoveRow(\'' + uid + '\', +2)">下移</a>';
			} else if(e.column.header == "+") {
				e.cellHtml = "+";
			} else if(e.column.header == "-") {
				e.cellHtml = "-";
			}
		});
		// 移动行数据
		function detailButtonGridMoveRow(row_uid, count) {
			var row = detailButtonGrid.getRowByUID(row_uid);
			var index = detailButtonGrid.indexOf(row);
			detailButtonGrid.moveRow(row, index + count);
		}
		// 标题栏点击事件
		detailButtonGrid.on("headercellclick", function(e) {
			// 如果点击了标题栏的加号，则增加一行
			if(e.column.header == "+") {
				adddetailButtonGridField(0);
			}
		});
		// 单元格点击事件
		detailButtonGrid.on("cellclick", function(e) {
			var data = detailButtonGrid.getSelected();
			var index = detailButtonGrid.indexOf(data);
			var header = e.column.header;
			// 如果点击了加号一列的单元格，则在当前行下面增加一行
			if(header == "+") {
				adddetailButtonGridField(index + 1);
			}
			// 如果点击了减号一列的单元格，则删除当前行
			else if(header == "-") {
				mini.confirm("确认删除该数据信息吗？", "删除操作", function(e) {
					if(e == "ok") {
						detailButtonGrid.removeRow(data);
					}
				});
			}
		});
		// 在指定的行号处添加一行记录
		function adddetailButtonGridField(index) {
			detailButtonGrid.addRow({
				"+": "+",
				"-": "-"
			}, index);
		}

		/************************************************************************
		 * 详情-表单-字段定义
		 ************************************************************************/
		var detailFieldGrid = mini.get("detailFieldGrid");
		detailFieldGrid.set({
			url: http.getUrl("/plat/field/list.do")
		});
		detailFieldGrid.on("drawcell", function(e) {
			//action列，超连接操作按钮
			if(e.column.name == "sequence") {
				var uid = e.record._uid;
				e.cellStyle = "text-align:center";
				e.cellHtml = '<a href="javascript:detailFieldGridMoveRow(\'' + uid + '\', -1)">上移</a>&nbsp; ' +
					'<a href="javascript:detailFieldGridMoveRow(\'' + uid + '\', +2)">下移</a>';
			}
		});
		// 移动行数据
		function detailFieldGridMoveRow(row_uid, count) {
			var row = detailFieldGrid.getRowByUID(row_uid);
			var index = detailFieldGrid.indexOf(row);
			detailFieldGrid.moveRow(row, index + count);
		}

		function openSelectTableDialog(e) {
			var field = e.source;
			// debugger
			mini.open({
				url: ctx + '/page/platform/win_table_select.html',
				title: "选择表或视图",
				width: 650,
				height: 550,
				onload: function() {
					var data = e.source.text;
					if(data != "") {
						var iframe = this.getIFrameEl();
						iframe.contentWindow.setData(data);
					}
				},
				ondestroy: function(action) {
					if(action == "ok") {
						var iframe = this.getIFrameEl();

						var data = iframe.contentWindow.getData();
						data = mini.clone(data); //必须

						e.source.setText(data.tableName);
						var name = e.source.name;
						var obj = {};
						if(name == "listTableName") {
							var obj = {
								"listTableName": data.tableName,
								"listTableID": data.tableID
							};
							listFieldGrid.load({
								tableID: data.tableID
							});
						} else {
							var obj = {
								"detailTableName": data.tableName,
								"detailTableID": data.tableID
							};
							detailFieldGrid.load({
								tableID: data.tableID
							});
						}
						basicForm.setData(obj, false);
					}
				}
			});
		}

		function openSelectClassDialog(e) {
			var field = e.source;
			// debugger
			mini.open({
				url: ctx + '/page/platform/win_class_select.html',
				title: "选择表或视图",
				width: 650,
				height: 550,
				onload: function() {
					var data = e.source.text;
					if(data != "") {
						var iframe = this.getIFrameEl();
						iframe.contentWindow.setData(data);
					}
				},
				ondestroy: function(action) {
					if(action == "ok") {
						var iframe = this.getIFrameEl();

						var data = iframe.contentWindow.getData();
						data = mini.clone(data); //必须

						e.source.setText(data.className);
						var obj = {
							"listTableName": data.tableName,
							"listTableID": data.tableID
						};
						listFieldGrid.load({
							tableID: data.tableID
						});
						detailFieldGrid.load({
							tableID: data.tableID
						});
						basicForm.setData(obj, false);
					}
				}
			});
		}

		function setData(data) {
			data = mini.clone(data);
			var pageID = data.pageID;
			http.get(http.getUrl("/plat/page/get.do?pageID=" + pageID), function(page) {
				var data = page.data;
				basicForm.setData(data);
				// debugger
				mini.get("listTableName").setText(data.listTableName);
				mini.get("listTableName").setValue(data.listTableName);
				mini.get("detailTableName").setText(data.detailTableName);
				mini.get("detailTableName").setValue(data.listTableName);
				var content = mini.decode(data.data);
				listSearchGrid.setData(content.list_search);
				listButtonGrid.setData(content.list_button);
				listFieldGrid.setData(content.list_field);

				detailBasicForm.setData(content.detailBasic);
				detailButtonGrid.setData(content.detail_button);
				detailFieldGrid.setData(content.detail_field);
			});
		}

		function doSave() {
			mini.mask({
				el: document.body,
				cls: 'mini-mask-loading',
				html: '数据保存中...'
			});
			var data = basicForm.getData();
			var list_search = miniui.getCleanGridData(listSearchGrid);
			var list_button = miniui.getCleanGridData(listButtonGrid);
			var list_field = miniui.getCleanGridData(listFieldGrid);

			var detail_button = miniui.getCleanGridData(detailButtonGrid);
			var detail_field = miniui.getCleanGridData(detailFieldGrid);
			var content = {};
			content["list_search"] = list_search;
			content["list_button"] = list_button;
			content["list_field"] = list_field;
			content["detail_button"] = detail_button;
			content["detail_field"] = detail_field;
			content["detailBasic"] = detailBasicForm.getData();
			debugger
			data["data"] = mini.encode(content);
			http.post("/plat/page/save.do", data, function(page) {
				mini.unmask();
				mini.alert("保存成功", "提示", null);
			});
		}

		function doCreate() {
			var data = basicForm.getData();
			http.post("/plat/page/create.do", data, function(page) {
				mini.unmask();
				mini.alert("文件成功生成了", "提示", null);
			});
		}
	</script>

</html>